﻿package  {
	public class Radar extends LineChart{
		private var angle:Number;
		
		public function Radar()
		{
			super();
		}		
		
		protected override function ScaleY(dataPoint:Number) : Number
		{
			return stageHeight - (dataPoint / largestPoint * (stageHeight / 2));
		}

		public override function Init(sw:Number, sh:Number)
		{
			stageWidth = sw;
			stageHeight = sh;
			
			var lines:Number = dataPoints.length;
			var spread:Number = stageWidth / (lines * 2);
			var center:Number = stageWidth / 2;
			
			angle = 360 / dataPoints.length * Math.PI / 180;
			
			graphics.clear();
			graphics.lineStyle(1, colorArray[0]);
			graphics.beginFill(colorArray[0], 0.5);
			
			for(var currentSpread:Number = spread; currentSpread < stageWidth; currentSpread += spread)
			{
				graphics.moveTo(
					center - currentSpread * Math.cos(0),
					center - currentSpread * Math.sin(0));
				for(var i:int = 1; i <= lines; i++)
				{
					graphics.lineTo(
						center - currentSpread * Math.cos(angle * i),
						center - currentSpread * Math.sin(angle * i));
				}
			}
			
			//graphics.lineStyle(1, 0x666666);
			graphics.endFill();
		}
	}
}